import os
env = Environment(ENV = os.environ)
env['SDK_ROOT'] = Dir('../../../../')
env.SConscript(env['SDK_ROOT'].File('soc/SConscript'),exports=['env'])
src = [    
    'FlashDev.c',
    'FlashPrg.c',
]
inc = [
    '.'
]
env['LINKSCRIPT'] = File(env.subst('flash_prog_link.txt'))
target = env.image_build('flash_prog',src,inc)
env.Append(CPPDEFINES = ['GLOBAL_OUTPUT_LVL=0', 'FLASH_PROG_ALGO'])
env.Append(CCFLAGS = ['-fPIE'])
env.Append(LINKFLAGS = ' -nostartfiles -Wl,-n ')
env.AddPostAction(target,Copy('${SDK_ROOT}/tools/prog/LinkedSemi/${IC}_flash_algo.elf','$TARGET'))